/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.mes.base.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.mes.base.entity.PrdInfo;
import org.springblade.modules.mes.base.vo.PrdInfoVO;

import java.util.Date;
import java.util.List;

/**
 * 产品信息 Mapper 接口
 *
 * @author BladeX
 * @since 2020-09-08
 */
public interface PrdInfoMapper extends BaseMapper<PrdInfo> {

	/**
	 * 不分页
	 * @param prdInfoVO
	 * @return
	 */
	List<PrdInfoVO> getPrdInfoVOList(PrdInfoVO prdInfoVO);

	/**
	 * 不分页
	 * 根据名称模糊搜索，如果没传返回空
	 * @param prdName
	 * @return
	 */
	List<PrdInfoVO> listByName(@Param("prdName") String prdName, @Param("productType") String productType, @Param("tenantId") String tenantId);


	/**
	 * 不分页
	 * 根据名称模糊搜索，如果没传返回空
	 * @param prdName
	 * @return
	 */
	List<PrdInfoVO> listByNameQua(@Param("prdName") String prdName, @Param("productType") String productType, @Param("tenantId") String tenantId);

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param prdInfo
	 * @return
	 */
	List<PrdInfoVO> selectPrdInfoPage(IPage page, PrdInfoVO prdInfo);

	/**
	 * 顶层产品列表 分页
	 *
	 * @param page
	 * @param prdInfo
	 * @return
	 */
	List<PrdInfoVO> selectTopPrdInfoPage(IPage page, PrdInfoVO prdInfo);

	/**
	 * 根据产品图号查询数量
	 * @param prdInfo
	 * @return
	 */
	int selectCountByDrawingNo(PrdInfo prdInfo);

	List<PrdInfoVO> listOfPrdNo(@Param("materialNo") String materialNo, @Param("tenantId") String tenantId);

	/**
	 * 产品列表，带产品类型
	 * @return
	 */
	List<PrdInfoVO> listWithType();

	/**
	 * 根据更新时间查询产品列表，包含已删除的
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	List<PrdInfo> listWithDeleted(Date startTime, Date endTime, String tenantId);

	/**
	 * 根据产品编码查询数量
	 * 包含已删除的
	 * @param prdInfoVO
	 */
	int countByMaterialNo(PrdInfoVO prdInfoVO);

	/**
	 * 根据物料类型和物料组查询所有物料
	 * @param prdInfo
	 * @return
	 */
	List<PrdInfoVO> materialByTypeAndGroup(PrdInfoVO prdInfo);

	/**
	 * 验证产品名称+规格+型号是否重复
	 * @param id
	 * @param materialName
	 * @param specifications
	 * @param model
	 * @return
	 */
    int countByNameSpecModel(@Param("id") Long id, @Param("materialName") String materialName, @Param("specifications") String specifications, @Param("model") String model, @Param("tenantId") String tenantId);

	List<String> getName();

    PrdInfoVO findByMaterialNo(String materialNo);

    boolean updateProductUnitPrice(@Param("entity") PrdInfoVO prdInfoVO);

    List<PrdInfoVO> selectByIds(@Param("idList") List<Long> toLongList);

    boolean updateByNoList(@Param("prdInfoList") List<PrdInfo> prdInfoList);
}
